package com.lmy.springCloud.service.Impl;

import com.lmy.springCloud.dao.AccountDao;
import com.lmy.springCloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    @Override
    public void reduce(Long userId, Integer money) {
//        try {
//            //模拟异常，超时
//            //openFeign接口调用默认超时时间为1s
//            TimeUnit.SECONDS.sleep(12);
//        } catch (InterruptedException e) {
//            log.error(e.getMessage());
//        }
        log.info("===========seata_account_micro_service_20091 扣减账户余额start============");
        accountDao.reduce(userId, money);
        log.info("===========seata_account_micro_service_20091 扣减账户余额end============");
    }
}
